package com.example.generator.domain;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;

/**
 * (Order)实体类
 *
 * @author makejava
 * @since 2024-10-17 19:49:14
 */
@TableName("t_order")
@Data
@NoArgsConstructor
public class Order implements Serializable {
    private static final long serialVersionUID = 921154189038617714L;
    /**
     * 订单ID
     */
    @TableId(type = IdType.AUTO)
    @JsonProperty("orderId")
    private Integer orderId;
    /**
     * 订单日期
     */
    private String orderDate;
    /**
     * 销售ID
     */
    private Integer salesmanId;
    /**
     * 销售员
     */
    private String salesmanName;
    /**
     * 车重
     */

    @JsonProperty("carWeight")
    private BigDecimal carWeight = new BigDecimal(0.0);
    /**
     * 毛重
     */
    @JsonProperty("grossWeight")
    private BigDecimal grossWeight =  new BigDecimal(0.0);
    /**
     * 打包重量
     */
    @JsonProperty("packageWeight")
    private BigDecimal packageWeight =  new BigDecimal(0.0);
    /**
     * 豆芽数量
     */
    @JsonProperty("beanSprouts")
    private BigDecimal beanSprouts =  new BigDecimal(0.0);
    /**
     * 豆芽单价
     */
    private BigDecimal beanSproutsPrice = new BigDecimal(0.6);
    /**
     * 豆芽总价
     */
    private BigDecimal beanSproutsTotalPrice =  new BigDecimal(0.0);
    /**
     * 芽了数量
     */
    @JsonProperty("litterBeanSprouts")
    private BigDecimal litterBeanSprouts =  new BigDecimal(0.0);
    /**
     * 芽了单价
     */
    private BigDecimal litterBeanSproutsPrice = new BigDecimal(1.2);
    /**
     * 芽了总价
     */
    private BigDecimal litterBeanSproutsTotalPrice =  new BigDecimal(0.0);;

    private BigDecimal totalPrice= new BigDecimal(0.0);;
    /**
     * 添加时间
     */
    private Date addTime;
    /**
     * 修改时间
     */
    private Date updateTime;

    private Integer sortId;

    public void calculate(){
        beanSprouts=grossWeight.subtract(carWeight).multiply(new BigDecimal(2)).add(packageWeight);
        beanSproutsTotalPrice=beanSprouts.multiply(beanSproutsPrice);
        litterBeanSproutsTotalPrice=litterBeanSprouts.multiply(litterBeanSproutsPrice);
        totalPrice=beanSproutsTotalPrice.add(litterBeanSproutsTotalPrice);
        updateTime=new Date();
    }

    public BigDecimal getTotalPrice() {
        return totalPrice.setScale(2, BigDecimal.ROUND_HALF_UP);
    }

    public BigDecimal getBeanSprouts() {
        return beanSprouts.setScale(2, BigDecimal.ROUND_HALF_UP);
    }
}

